package frame;

import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;

import javax.swing.ImageIcon;

public class MScaleIcon extends ImageIcon {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4713091812565814440L;

	public MScaleIcon(String filename) {
		super(filename);
	}

	@Override
	public void paintIcon(Component c, Graphics g, int x, int y) {
		int width = c.getWidth();
		int height = c.getHeight();
		int imgWidth = getIconWidth();
		int imgHeight = getIconHeight();

		Graphics2D g2d = (Graphics2D) g;
		g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
		g2d.drawImage(getImage(), 0, 0, width, height, 0, 0, imgWidth, imgHeight, getImageObserver());
	}

}
